﻿using mqtt.client.test.Mqtt;
using mqtt.client.test.Mqtt.Connect;
using mqtt.client.test.Mqtt.Constant;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XjjXmm.Infrastructure.Common;
using XjjXmm.Infrastructure.Exceptions;

namespace mqtt.client.test.Output;

internal class ConnectOutput
{
    private readonly ArraySegment<byte> buffer;

    public ConnectOutput(ArraySegment<byte> buffer)
    {
        this.buffer = buffer;
    }

    public Response<string> Result()
    {
        var returnCode = buffer[3];
        switch (returnCode)
        {
            case 0:
                return new Response<string>("");
            case 0x01:
                return new Response<string>("0x01连接已拒绝，不支持的协议版本");
            case 0x02:
                return new Response<string>("0x02连接已拒绝，不合格的客户端标识符");
            case 0x03:
                return new Response<string>("0x03连接已拒绝，服务端不可用");
            case 0x04:
                return new Response<string>("0x04连接已拒绝，无效的用户名或密码");
            case 0x05:
                return new Response<string>("0x05连接已拒绝，未授权");
            default:
                return new Response<string>("未知异常");
        }
    }


}
